package search.items;

import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import domain.items.Post;

public class SearchDB {
	
	/**
	 * name of the file to which the Search DataBase will be saved 
	 */
	public final static String FILE_NAME = "searchDB.xml";


	
	/**
	 * map each word to an ID number
	 */
	protected Map<String, Long> _wordsIndex;


	/**
	 * map each post to an ID number. the ID number is part of the information of the Post
	 * and can be find within it.
	 */
	protected Map<Long, Post> _postsIndex;


	/**
	 * map each wordID to a list of PostID, where each post matching the PostID contains the word that match the WordID
	 */
	protected Map<Long, Set<Long>> _wordsToPostsIndex;


	/**
	 * map each userName to a list of postIDs, where each postID matches a post that was written by this user
	 */
	protected Map<String, Set<Long>> _usersToPostsIndex;


	/**
	 * map date to a list of postIDs, where each postID matches a post that was written at that date
	 */
	protected Map<Calendar, Set<Long>> _datesToPostsIndex;
	
	
	/**
	 * Constructor
	 * create an empty DB 
	 */
	public SearchDB() {
		this._postsIndex = new HashMap<Long, Post>();
		this._wordsIndex = new HashMap<String, Long>();
		this._wordsToPostsIndex = new HashMap<Long, Set<Long>>();
		this._usersToPostsIndex = new HashMap<String, Set<Long>>();
		this._datesToPostsIndex = new HashMap<Calendar, Set<Long>>();		
	}

}
